package com.xuanwei.core.response;


import com.xuanwei.core.enums.ResponseCode;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;


@Data
@Accessors(chain = true)
public class ResultVO<T> implements Serializable {
    /**
     * 响应码
     */
    private Integer code;
    /**
     * 响应信息
     */
    private String message;
    /**
     * 响应数据
     */
    private T data;


    public static<T> ResultVO<T> successResult(){
        return new ResultVO<T>().setCode(ResponseCode.SUCCESS.getCode()).setMessage(ResponseCode.SUCCESS.getMessage());
    }
    public static<T> ResultVO<T> successResult(String message){
        return new ResultVO<T>().setCode(ResponseCode.SUCCESS.getCode()).setMessage(message);
    }
    public static<T> ResultVO<T> successResult(T data){
        return new ResultVO<T>().setCode(ResponseCode.SUCCESS.getCode()).setMessage(ResponseCode.SUCCESS.getMessage()).setData(data);
    }
    public static<T> ResultVO<T> successResult(String message,T data){
        return new ResultVO<T>().setCode(ResponseCode.SUCCESS.getCode()).setMessage(message).setData(data);
    }

    public static<T> ResultVO<T> failResult(){
        return new ResultVO<T>().setCode(ResponseCode.FAIL.getCode()).setMessage(ResponseCode.FAIL.getMessage());
    }

    public static<T> ResultVO<T> failResult(String message){
        return new ResultVO<T>().setCode(ResponseCode.FAIL.getCode()).setMessage(message);
    }

    public static<T> ResultVO<T> authFail(){
        return new ResultVO<T>().setCode(ResponseCode.AUTHERROR.getCode()).setMessage(ResponseCode.AUTHERROR.getMessage());
    }

    public static<T> ResultVO<T> authFail(String message){
        return new ResultVO<T>().setCode(ResponseCode.AUTHERROR.getCode()).setMessage(message);
    }

    public static<T> ResultVO<T> LoginFail(){
        return new ResultVO<T>().setCode(ResponseCode.LOGINERROR.getCode()).setMessage(ResponseCode.LOGINERROR.getMessage());
    }

}
